package br.com.caiocarrara.goodbuy.tests;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import br.com.caiocarrara.goodbuy.dao.ProductDao;
import br.com.caiocarrara.goodbuy.infra.SessionCreator;
import br.com.caiocarrara.goodbuy.infra.SessionFactoryCreator;
import br.com.caiocarrara.goodbuy.model.Product;

public class AddProduct {
	
	public static void main(String[] args) {		
		Product product = buildProduct();
		SessionFactory factory = new SessionFactoryCreator().getInstance();
		Session session = new SessionCreator(factory).getInstance();
		new ProductDao(session).save(product);
	}

	private static Product buildProduct() {
		Product product = new Product();
		product.setDescription("Smartphone Motorola RAZR i XPTO");
		product.setName("Motorola RAZR i");
		product.setPrice(1200.0);
		return product;
	}
}
